﻿using MediatR;
using Traceability.APP.Application.Command.Deep;
using Traceability.Domain;
using Traceability.ErrorCode;
using Traceability.Infrerture.Interfaces;

namespace Traceability.APP.Application.CommandHandle.Deep
{
    /// <summary>
    /// 深加工的显示
    /// </summary>
    public class ShowDeepCommandHandle:IRequestHandler<ShowDeepCommand,APIResult<List<Deep_Model>>>
    {
        private readonly IBaseRepository<Deep_Model> DeepDal;

        public ShowDeepCommandHandle(IBaseRepository<Deep_Model> deepDal)
        {
            DeepDal = deepDal;
        }
        
        public Task<APIResult<List<Deep_Model>>> Handle(ShowDeepCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<Deep_Model>> result = new APIResult<List<Deep_Model>>();
             var list = DeepDal.GetAll().Where(x => x.Batch == request.Batch && x.IsDeleted == false);
            result.Code = StateCode.Ok;
            result.Message = StateCode.Ok.ToString();
            result.Data = list.ToList();
            return Task.FromResult(result);
        }



    }
}
